package com.decent.common.validator;

import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 文件验证
 *
 * @author: wangyan
 * @date: 2021/12/16
 */
public class CheckFileNotNullValidator implements ConstraintValidator<CheckFileNotNull, MultipartFile> {
    @Override
    public void initialize(CheckFileNotNull constraintAnnotation) {
    }

    @Override
    public boolean isValid(MultipartFile multipartFile, ConstraintValidatorContext constraintValidatorContext) {
        return multipartFile != null && StrUtil.isNotBlank(multipartFile.getOriginalFilename());
    }

}
